import request from '@/utils/request'

/**
* @desc 添加用户
* @param {Object}} query 
* @returns 
*/
export function insertMyRequestInfo(data) {
  return request({
    url: '/requestinfo/myRequestInfo/insertMyRequestInfo',
    method: 'POST',
    data: data
  })
}

/**
* @desc 判断是否是好友
* @param {Object}} query 
* @returns 
*/
export function myRequestInfo(data) {
  return request({
    url: '/requestinfo/myRequestInfo/selectByBuddyInfoAccount',
    method: 'POST',
    data: data
  })
}

/**
* @desc 搜索好友列表
* @param {Object}} query 
* @returns 
*/
export function selectUserByUserName(query) {
  return request({
    url: '/requestinfo/myRequestInfo/selectUserByUserName',
    method: 'GET',
    params: query
  })
}


/**
* @desc 获取申请信息
* @param {Object}} query 
* @returns 
*/
export function getReplyBuddyInfoList(query) {
  return request({
    url: '/requestinfo/myRequestInfo/getReplyBuddyInfoList',
    method: 'GET',
    params: query
  })
}



/**
* @desc 同意好友申请
* @param {Object}} query 
* @returns 
*/
export function updateMyRequestInfo(data) {
  return request({
    url: '/requestinfo/myRequestInfo/updateMyRequestInfo',
    method: 'POST',
    data: data
  })
}



/**
* @desc 获取好友列表
* @param {Object}} query 
* @returns 
*/
export function _getBuddyInfoList(data) {
  return request({
    url: '/requestinfo/myRequestInfo/getBuddyInfoList',
    method: 'GET',
    params: data,
  })
}

/**
* @desc 删除好友列表
* @param {Object}} query 
* @returns 
*/
export function deleteBuddyInfo(id) {
  return request({
    url: '/requestinfo/myRequestInfo/deleteBuddyInfo/' + id,
    method: 'DELETE',
  })
}

/**
* @desc 同意申请返回信息
* @param {Object}} query 
* @returns 
*/
export function _refuseStatus(data) {
  return request({
    url: '/requestinfo/myRequestInfo/refuseStatus',
    method: 'POST',
    data: data
  })
}




/**
* @desc 获取地理位置
* @param {Object}} query 
* @returns 
*/
export function getaddress() {
  let xhr = new XMLHttpRequest();
  xhr.open(
    "GET",
    "/location/ip?ak=iFY1Qg56OGMGmU39sbjYUhpcX98GACrl&ip=&coor=bd09ll"
  );
  xhr.send();
  return new Promise((resolve) => {
    xhr.onreadystatechange = function () {
      let obj = {
        status: xhr.status,
        data: xhr.responseText,
      }
      if (xhr.readyState == 4 && xhr.status == 200) {
        resolve(obj)
      }
    }
  })
}